﻿using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;
using Common.Base;
using Security.ERP;
using APP.HELPER.Utils.Language;
using Common.Class;
using Extra.ERP;
using Common;
using Common.Report;

namespace Security.Security
{
    public class xucPermision : xucBase
    {
        private Bar bar1;
        private BarDockControl barDockControlBottom;
        private BarDockControl barDockControlLeft;
        private BarDockControl barDockControlRight;
        private BarDockControl barDockControlTop;
        private BarManager barManager1;
        private BarButtonItem bbiClose;
        private BarButtonItem bbiDelete;
        private BarButtonItem bbiEdit;
        private BarButtonItem bbiExport;
        private BarButtonItem bbiGroupAdd;
        private BarButtonItem bbiPrint;
        private BarButtonItem bbiRefresh;
        private BarButtonItem bbiSave;
        private BarButtonItem bbiUserAdd;
        private TreeListColumn colActive;
        private TreeListColumn colAllowAccess;
        private TreeListColumn colAllowAdd;
        private TreeListColumn colAllowDelete;
        private TreeListColumn colAllowEdit;
        private TreeListColumn colAllowExport;
        private TreeListColumn colAllowImport;
        private TreeListColumn colAllowPrint;
        private TreeListColumn colObject_Name;
        private IContainer components = null;
        private GridColumn gridColumn1;
        private GridColumn gridColumn10;
        private GridColumn gridColumn11;
        private GridColumn gridColumn12;
        private GridColumn gridColumn13;
        private GridColumn gridColumn14;
        private GridColumn gridColumn15;
        private GridColumn gridColumn16;
        private GridColumn gridColumn17;
        private GridColumn gridColumn18;
        private GridColumn gridColumn19;
        private GridColumn gridColumn2;
        private GridColumn gridColumn20;
        private GridColumn gridColumn3;
        private GridColumn gridColumn4;
        private GridColumn gridColumn5;
        private GridColumn gridColumn6;
        private GridColumn gridColumn7;
        private GridColumn gridColumn8;
        private GridColumn gridColumn9;
        public DevExpress.Utils.ImageCollection imageCollection2;
        private string m_GroupID = "admin";
        private int m_Level = 0;
        private string m_UserID = "";
        private RepositoryItemImageComboBox repositoryItemImageComboBox1;
        private RepositoryItemPictureEdit repositoryItemPictureEdit1;
        private SplitContainerControl splitContainerControl1;
        private TreeList tlPermision;
        private xucGroupUser xucGroupUser1;

        public xucPermision()
        {
            this.InitializeComponent();
            this.Init();
        }

        private void bbiClose_ItemClick(object sender, ItemClickEventArgs e)
        {
            base.ParentForm.Close();
        }

        private void bbiDelete_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (this.m_Level == 0)
            {
                this.xucGroupUser1.GroupDelete();
            }
            else
            {
                this.xucGroupUser1.UserDelete();
            }
        }

        private void bbiEdit_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (this.m_Level == 0)
            {
                this.xucGroupUser1.GroupEdit();
            }
            else
            {
                this.xucGroupUser1.UserEdit();
            }
        }

        private void bbiExport_ItemClick(object sender, ItemClickEventArgs e)
        {
            SYS_LOG.Insert("Danh S\x00e1ch Nh\x00e2n Vi\x00ean", "Xuất");
            base.Export(this.tlPermision);
        }

        private void bbiGroupAdd_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.xucGroupUser1.GroupAdd();
        }

        private void bbiPrint_ItemClick(object sender, ItemClickEventArgs e)
        {
            new xfmReport("Ph\x00e2n Quyền").ShowPrintPreview(this.tlPermision);
        }

        private void bbiSave_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (this.m_GroupID == "admin")
            {
                XtraMessageBox.Show("Nh\x00f3m người d\x00f9ng n\x00e0y kh\x00f4ng được thay đổi", "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string str = "";
                MyRule.Check("bbiUserGroup");
                if (!MyRule.AllowEdit | !MyRule.AllowAdd)
                {
                    MyRule.Notify();
                }
                else
                {
                    SYS_LOG.Insert("Ph\x00e2n Quyền Người D\x00f9ng", "Cập Nhật", this.m_GroupID);
                    DataTable dataSource = this.tlPermision.DataSource as DataTable;
                    for (int i = 0; i < dataSource.Rows.Count; i++)
                    {
                        if (dataSource.Rows[i].RowState == DataRowState.Modified)
                        {
                            str = MyRule.Update(this.m_GroupID, dataSource.Rows[i]["Object_ID"].ToString(), dataSource.Rows[i]["Rule_ID"].ToString(), Convert.ToBoolean(dataSource.Rows[i]["AllowAdd"]), Convert.ToBoolean(dataSource.Rows[i]["AllowDelete"]), Convert.ToBoolean(dataSource.Rows[i]["AllowEdit"]), Convert.ToBoolean(dataSource.Rows[i]["AllowAccess"]), Convert.ToBoolean(dataSource.Rows[i]["AllowPrint"]), Convert.ToBoolean(dataSource.Rows[i]["AllowExport"]), Convert.ToBoolean(dataSource.Rows[i]["AllowImport"]), Convert.ToBoolean(dataSource.Rows[i]["Active"]));
                        }
                    }
                    if (str == "OK")
                    {
                        this.DoHide();
                        XtraMessageBox.Show("Dữ liệu đ\x00e3 được lưu th\x00e0nh c\x00f4ng.", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
            }
        }

        private void bbiUserAdd_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.xucGroupUser1.UserAdd();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Init()
        {
            this.xucGroupUser1.LoadData();
            this.tlPermision.DataSource = MyRule.GetList("admin", MultiLanguages.Language(), Options.SoftId);
            this.xucGroupUser1.Selected += delegate(object o, GroupUser i)
            {
                if (i.Level == 0)
                {
                    this.m_Level = 0;
                    this.tlPermision.DataSource = MyRule.GetList(this.m_GroupID = i.GroupID, SysOption.Language, Options.SoftId);
                }
                else
                {
                    this.m_Level = 1;
                    SYS_USER sys_user = new SYS_USER();
                    sys_user.Get(this.m_UserID = i.UserID);
                    this.tlPermision.DataSource = MyRule.GetList(this.m_GroupID = sys_user.Group_ID, SysOption.Language, Options.SoftId);
                }
                this.tlPermision.ExpandAll();
            };
            this.tlPermision.ExpandAll();
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            MenuButton button = new MenuButton();
            ItemCommand command = new ItemCommand();
            ItemCommand command2 = new ItemCommand();
            ItemCommand command3 = new ItemCommand();
            ItemCommand command4 = new ItemCommand();
            ItemCommand command5 = new ItemCommand();
            ItemCommand command6 = new ItemCommand();
            ItemCommand command7 = new ItemCommand();
            ItemCommand command8 = new ItemCommand();
            ItemCommand command9 = new ItemCommand();
            ItemCommand command10 = new ItemCommand();
            ItemCommand command11 = new ItemCommand();
            ItemCommand command12 = new ItemCommand();
            ItemCommand command13 = new ItemCommand();
            ItemCommand command14 = new ItemCommand();
            ItemCommand command15 = new ItemCommand();
            ItemCommand command16 = new ItemCommand();
            ItemCommand command17 = new ItemCommand();
            ItemCommand command18 = new ItemCommand();
            ItemCommand command19 = new ItemCommand();
            ItemCommand command20 = new ItemCommand();
            ItemCommand command21 = new ItemCommand();
            ItemCommand command22 = new ItemCommand();
            ItemCommand command23 = new ItemCommand();
            ItemCommand command24 = new ItemCommand();
            ItemCommand command25 = new ItemCommand();
            ItemCommand command26 = new ItemCommand();
            ItemCommand command27 = new ItemCommand();
            ItemCommand command28 = new ItemCommand();
            ItemCommand command29 = new ItemCommand();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucPermision));
            this.repositoryItemPictureEdit1 = new RepositoryItemPictureEdit();
            this.splitContainerControl1 = new SplitContainerControl();
            this.xucGroupUser1 = new xucGroupUser();
            this.tlPermision = new TreeList();
            this.colObject_Name = new TreeListColumn();
            this.colActive = new TreeListColumn();
            this.colAllowAccess = new TreeListColumn();
            this.colAllowAdd = new TreeListColumn();
            this.colAllowEdit = new TreeListColumn();
            this.colAllowDelete = new TreeListColumn();
            this.colAllowPrint = new TreeListColumn();
            this.colAllowImport = new TreeListColumn();
            this.colAllowExport = new TreeListColumn();
            this.gridColumn1 = new GridColumn();
            this.gridColumn2 = new GridColumn();
            this.gridColumn3 = new GridColumn();
            this.gridColumn4 = new GridColumn();
            this.gridColumn5 = new GridColumn();
            this.gridColumn6 = new GridColumn();
            this.gridColumn7 = new GridColumn();
            this.gridColumn8 = new GridColumn();
            this.gridColumn9 = new GridColumn();
            this.gridColumn10 = new GridColumn();
            this.gridColumn11 = new GridColumn();
            this.gridColumn12 = new GridColumn();
            this.gridColumn13 = new GridColumn();
            this.gridColumn14 = new GridColumn();
            this.gridColumn15 = new GridColumn();
            this.gridColumn16 = new GridColumn();
            this.gridColumn17 = new GridColumn();
            this.gridColumn18 = new GridColumn();
            this.gridColumn19 = new GridColumn();
            this.gridColumn20 = new GridColumn();
            this.barManager1 = new BarManager(this.components);
            this.bar1 = new Bar();
            this.bbiGroupAdd = new BarButtonItem();
            this.bbiUserAdd = new BarButtonItem();
            this.bbiEdit = new BarButtonItem();
            this.bbiDelete = new BarButtonItem();
            this.bbiSave = new BarButtonItem();
            this.bbiPrint = new BarButtonItem();
            this.bbiExport = new BarButtonItem();
            this.bbiRefresh = new BarButtonItem();
            this.bbiClose = new BarButtonItem();
            this.barDockControlTop = new BarDockControl();
            this.barDockControlBottom = new BarDockControl();
            this.barDockControlLeft = new BarDockControl();
            this.barDockControlRight = new BarDockControl();
            this.imageCollection2 = new DevExpress.Utils.ImageCollection(this.components);
            this.repositoryItemImageComboBox1 = new RepositoryItemImageComboBox();
            this.repositoryItemPictureEdit1.BeginInit();
            this.splitContainerControl1.BeginInit();
            this.splitContainerControl1.SuspendLayout();
            this.tlPermision.BeginInit();
            this.barManager1.BeginInit();
            this.imageCollection2.BeginInit();
            this.repositoryItemImageComboBox1.BeginInit();
            base.SuspendLayout();
            this.repositoryItemPictureEdit1.Name = "repositoryItemPictureEdit1";
            this.splitContainerControl1.Dock = DockStyle.Fill;
            this.splitContainerControl1.Location = new Point(0, 0x1a);
            this.splitContainerControl1.Name = "splitContainerControl1";
            this.splitContainerControl1.Panel1.Controls.Add(this.xucGroupUser1);
            this.splitContainerControl1.Panel1.Text = "Panel1";
            this.splitContainerControl1.Panel2.Controls.Add(this.tlPermision);
            this.splitContainerControl1.Panel2.Text = "Panel2";
            this.splitContainerControl1.Size = new Size(0x3ec, 0x22e);
            this.splitContainerControl1.SplitterPosition = 0xd3;
            this.splitContainerControl1.TabIndex = 4;
            this.splitContainerControl1.Text = "splitContainerControl1";
            this.xucGroupUser1.Dock = DockStyle.Fill;
            this.xucGroupUser1.IsClose = CloseOrNew.None;
            this.xucGroupUser1.Location = new Point(0, 0);
            this.xucGroupUser1.Name = "xucGroupUser1";
            this.xucGroupUser1.NotSave = false;
            command.Caption = "";
            command.Enable = false;
            command.Visibility = BarItemVisibility.Never;
            button.Add = command;
            command2.Caption = "";
            command2.Enable = false;
            command2.Visibility = BarItemVisibility.Never;
            button.Cancel = command2;
            command3.Caption = "";
            command3.Enable = false;
            command3.Visibility = BarItemVisibility.Never;
            button.Change = command3;
            command4.Caption = "";
            command4.Enable = false;
            command4.Visibility = BarItemVisibility.Never;
            button.Close = command4;
            command5.Caption = "";
            command5.Enable = false;
            command5.Visibility = BarItemVisibility.Never;
            button.Custom = command5;
            command6.Caption = "";
            command6.Enable = false;
            command6.Visibility = BarItemVisibility.Never;
            button.Delete = command6;
            command7.Caption = "";
            command7.Enable = false;
            command7.Visibility = BarItemVisibility.Never;
            button.Export = command7;
            command8.Caption = "";
            command8.Enable = false;
            command8.Visibility = BarItemVisibility.Never;
            button.Filter = command8;
            command9.Caption = "";
            command9.Enable = false;
            command9.Visibility = BarItemVisibility.Never;
            button.FilterCustomer = command9;
            command10.Caption = "";
            command10.Enable = false;
            command10.Visibility = BarItemVisibility.Never;
            button.FilterStock = command10;
            command11.Caption = "";
            command11.Enable = false;
            command11.Visibility = BarItemVisibility.Never;
            button.Find = command11;
            button.GClose = false;
            button.GCommand = false;
            button.GExport = false;
            command12.Caption = "";
            command12.Enable = false;
            command12.Visibility = BarItemVisibility.Never;
            button.Go = command12;
            button.GOption = false;
            button.GPrint = false;
            button.GRecords = false;
            button.GSearchBar = false;
            button.GSettings = false;
            button.GVaildation = false;
            command13.Caption = "";
            command13.Enable = false;
            command13.Visibility = BarItemVisibility.Never;
            button.Import = command13;
            command14.Caption = "";
            command14.Enable = false;
            command14.Visibility = BarItemVisibility.Never;
            button.Next = command14;
            command15.Caption = "";
            command15.Enable = false;
            command15.Visibility = BarItemVisibility.Never;
            button.PageSetup = command15;
            button.PHome = false;
            command16.Caption = "";
            command16.Enable = false;
            command16.Visibility = BarItemVisibility.Never;
            button.Previous = command16;
            command17.Caption = "";
            command17.Enable = false;
            command17.Visibility = BarItemVisibility.Never;
            button.Print = command17;
            command18.Caption = "";
            command18.Enable = false;
            command18.Visibility = BarItemVisibility.Never;
            button.PrintPreview = command18;
            button.PTool = false;
            command19.Caption = "";
            command19.Enable = false;
            command19.Visibility = BarItemVisibility.Never;
            button.Redo = command19;
            command20.Caption = "";
            command20.Enable = false;
            command20.Visibility = BarItemVisibility.Never;
            button.Refresh = command20;
            command21.Caption = "";
            command21.Enable = false;
            command21.Visibility = BarItemVisibility.Never;
            button.Save = command21;
            command22.Caption = "";
            command22.Enable = false;
            command22.Visibility = BarItemVisibility.Never;
            button.SaveAndClose = command22;
            command23.Caption = "";
            command23.Enable = false;
            command23.Visibility = BarItemVisibility.Never;
            button.SaveAndNew = command23;
            command24.Caption = "";
            command24.Enable = false;
            command24.Visibility = BarItemVisibility.Never;
            button.Search = command24;
            command25.Caption = "";
            command25.Enable = false;
            command25.Visibility = BarItemVisibility.Never;
            button.SearchText = command25;
            command26.Caption = "";
            command26.Enable = false;
            command26.Visibility = BarItemVisibility.Never;
            button.Task = command26;
            command27.Caption = "";
            command27.Enable = false;
            command27.Visibility = BarItemVisibility.Never;
            button.Undo = command27;
            command28.Caption = "";
            command28.Enable = false;
            command28.Visibility = BarItemVisibility.Never;
            button.Vaildate = command28;
            command29.Caption = "";
            command29.Enable = false;
            command29.Visibility = BarItemVisibility.Never;
            button.View = command29;
            this.xucGroupUser1.RibbonBar = button;
            this.xucGroupUser1.Size = new Size(0xd3, 0x22e);
            this.xucGroupUser1.Status = Actions.None;
            this.xucGroupUser1.TabIndex = 0;
            this.xucGroupUser1.Title = "";
            this.tlPermision.Columns.AddRange(new TreeListColumn[] { this.colObject_Name, this.colActive, this.colAllowAccess, this.colAllowAdd, this.colAllowEdit, this.colAllowDelete, this.colAllowPrint, this.colAllowImport, this.colAllowExport });
            this.tlPermision.Dock = DockStyle.Fill;
            this.tlPermision.ImageIndexFieldName = "41";
            this.tlPermision.KeyFieldName = "Object_ID";
            this.tlPermision.Location = new Point(0, 0);
            this.tlPermision.Name = "tlPermision";
            this.tlPermision.OptionsPrint.PrintFilledTreeIndent = true;
            this.tlPermision.OptionsPrint.PrintPreview = true;
            this.tlPermision.OptionsPrint.PrintReportFooter = false;
            this.tlPermision.OptionsView.ShowIndicator = false;
            this.tlPermision.ParentFieldName = "Parent_ID";
            this.tlPermision.PreviewFieldName = "Parent_ID";
            this.tlPermision.Size = new Size(0x313, 0x22e);
            this.tlPermision.TabIndex = 1;
            this.tlPermision.CellValueChanging += new CellValueChangedEventHandler(this.tlPermision_CellValueChanging);
            this.colObject_Name.Caption = "Chức năng";
            this.colObject_Name.FieldName = "Object_Name";
            this.colObject_Name.MinWidth = 0x23;
            this.colObject_Name.Name = "colObject_Name";
            this.colObject_Name.OptionsColumn.AllowEdit = false;
            this.colObject_Name.OptionsColumn.ReadOnly = true;
            this.colObject_Name.Visible = true;
            this.colObject_Name.VisibleIndex = 0;
            this.colObject_Name.Width = 0xc5;
            this.colActive.AppearanceCell.Options.UseTextOptions = true;
            this.colActive.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colActive.AppearanceHeader.Options.UseTextOptions = true;
            this.colActive.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colActive.Caption = "Tất cả";
            this.colActive.FieldName = "Active";
            this.colActive.Name = "colActive";
            this.colActive.OptionsColumn.FixedWidth = true;
            this.colActive.Visible = true;
            this.colActive.VisibleIndex = 1;
            this.colActive.Width = 60;
            this.colAllowAccess.AppearanceCell.Options.UseTextOptions = true;
            this.colAllowAccess.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowAccess.AppearanceHeader.Options.UseTextOptions = true;
            this.colAllowAccess.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowAccess.Caption = "Truy cập";
            this.colAllowAccess.FieldName = "AllowAccess";
            this.colAllowAccess.Name = "colAllowAccess";
            this.colAllowAccess.OptionsColumn.FixedWidth = true;
            this.colAllowAccess.Visible = true;
            this.colAllowAccess.VisibleIndex = 2;
            this.colAllowAccess.Width = 60;
            this.colAllowAdd.AppearanceCell.Options.UseTextOptions = true;
            this.colAllowAdd.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowAdd.AppearanceHeader.Options.UseTextOptions = true;
            this.colAllowAdd.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowAdd.Caption = "Th\x00eam";
            this.colAllowAdd.FieldName = "AllowAdd";
            this.colAllowAdd.Name = "colAllowAdd";
            this.colAllowAdd.OptionsColumn.FixedWidth = true;
            this.colAllowAdd.Visible = true;
            this.colAllowAdd.VisibleIndex = 3;
            this.colAllowAdd.Width = 60;
            this.colAllowEdit.AppearanceCell.Options.UseTextOptions = true;
            this.colAllowEdit.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowEdit.AppearanceHeader.Options.UseTextOptions = true;
            this.colAllowEdit.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowEdit.Caption = "Sửa";
            this.colAllowEdit.FieldName = "AllowEdit";
            this.colAllowEdit.Name = "colAllowEdit";
            this.colAllowEdit.OptionsColumn.FixedWidth = true;
            this.colAllowEdit.Visible = true;
            this.colAllowEdit.VisibleIndex = 4;
            this.colAllowEdit.Width = 60;
            this.colAllowDelete.AppearanceCell.Options.UseTextOptions = true;
            this.colAllowDelete.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowDelete.AppearanceHeader.Options.UseTextOptions = true;
            this.colAllowDelete.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowDelete.Caption = "Xo\x00e1";
            this.colAllowDelete.FieldName = "AllowDelete";
            this.colAllowDelete.Name = "colAllowDelete";
            this.colAllowDelete.OptionsColumn.FixedWidth = true;
            this.colAllowDelete.Visible = true;
            this.colAllowDelete.VisibleIndex = 5;
            this.colAllowDelete.Width = 60;
            this.colAllowPrint.AppearanceCell.Options.UseTextOptions = true;
            this.colAllowPrint.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowPrint.AppearanceHeader.Options.UseTextOptions = true;
            this.colAllowPrint.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowPrint.Caption = "In";
            this.colAllowPrint.FieldName = "AllowPrint";
            this.colAllowPrint.Name = "colAllowPrint";
            this.colAllowPrint.OptionsColumn.FixedWidth = true;
            this.colAllowPrint.Visible = true;
            this.colAllowPrint.VisibleIndex = 6;
            this.colAllowPrint.Width = 60;
            this.colAllowImport.AppearanceCell.Options.UseTextOptions = true;
            this.colAllowImport.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowImport.AppearanceHeader.Options.UseTextOptions = true;
            this.colAllowImport.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowImport.Caption = "Nhập";
            this.colAllowImport.FieldName = "AllowImport";
            this.colAllowImport.Name = "colAllowImport";
            this.colAllowImport.OptionsColumn.FixedWidth = true;
            this.colAllowImport.Visible = true;
            this.colAllowImport.VisibleIndex = 7;
            this.colAllowImport.Width = 60;
            this.colAllowExport.AppearanceCell.Options.UseTextOptions = true;
            this.colAllowExport.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowExport.AppearanceHeader.Options.UseTextOptions = true;
            this.colAllowExport.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            this.colAllowExport.Caption = "Xuất";
            this.colAllowExport.FieldName = "AllowExport";
            this.colAllowExport.Name = "colAllowExport";
            this.colAllowExport.OptionsColumn.FixedWidth = true;
            this.colAllowExport.Visible = true;
            this.colAllowExport.VisibleIndex = 8;
            this.colAllowExport.Width = 60;
            this.gridColumn1.Name = "gridColumn1";
            this.gridColumn2.Name = "gridColumn2";
            this.gridColumn3.Name = "gridColumn3";
            this.gridColumn4.Name = "gridColumn4";
            this.gridColumn5.Name = "gridColumn5";
            this.gridColumn6.Name = "gridColumn6";
            this.gridColumn7.Name = "gridColumn7";
            this.gridColumn8.Name = "gridColumn8";
            this.gridColumn9.Name = "gridColumn9";
            this.gridColumn10.Name = "gridColumn10";
            this.gridColumn11.Name = "gridColumn11";
            this.gridColumn12.Name = "gridColumn12";
            this.gridColumn13.Name = "gridColumn13";
            this.gridColumn14.Name = "gridColumn14";
            this.gridColumn15.Name = "gridColumn15";
            this.gridColumn16.Name = "gridColumn16";
            this.gridColumn17.Name = "gridColumn17";
            this.gridColumn18.Name = "gridColumn18";
            this.gridColumn19.Name = "gridColumn19";
            this.gridColumn20.Name = "gridColumn20";
            this.barManager1.Bars.AddRange(new Bar[] { this.bar1 });
            this.barManager1.DockControls.Add(this.barDockControlTop);
            this.barManager1.DockControls.Add(this.barDockControlBottom);
            this.barManager1.DockControls.Add(this.barDockControlLeft);
            this.barManager1.DockControls.Add(this.barDockControlRight);
            this.barManager1.Form = this;
            this.barManager1.Images = this.imageCollection2;
            this.barManager1.Items.AddRange(new BarItem[] { this.bbiGroupAdd, this.bbiUserAdd, this.bbiSave, this.bbiDelete, this.bbiPrint, this.bbiRefresh, this.bbiClose, this.bbiExport, this.bbiEdit });
            this.barManager1.MaxItemId = 0x10;
            this.barManager1.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemImageComboBox1 });
            this.bar1.BarName = "Tools";
            this.bar1.DockCol = 0;
            this.bar1.DockRow = 0;
            this.bar1.DockStyle = BarDockStyle.Top;
            this.bar1.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiGroupAdd, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiUserAdd, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiEdit, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiDelete, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiSave, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiPrint, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiExport, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiRefresh, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiClose, BarItemPaintStyle.CaptionGlyph) });
            this.bar1.OptionsBar.UseWholeRow = true;
            this.bar1.Text = "Tools";
            this.bbiGroupAdd.Caption = "Th\x00eam Nh\x00f3m Người D\x00f9ng";
            this.bbiGroupAdd.Id = 0;
            this.bbiGroupAdd.ImageIndex = 0x16;
            this.bbiGroupAdd.Name = "bbiGroupAdd";
            this.bbiGroupAdd.ItemClick += new ItemClickEventHandler(this.bbiGroupAdd_ItemClick);
            this.bbiUserAdd.Caption = "Th\x00eam Người D\x00f9ng";
            this.bbiUserAdd.Id = 3;
            this.bbiUserAdd.ImageIndex = 0x15;
            this.bbiUserAdd.Name = "bbiUserAdd";
            this.bbiUserAdd.ItemClick += new ItemClickEventHandler(this.bbiUserAdd_ItemClick);
            this.bbiEdit.Caption = "Sửa";
            this.bbiEdit.Id = 15;
            this.bbiEdit.ImageIndex = 3;
            this.bbiEdit.Name = "bbiEdit";
            this.bbiEdit.ItemClick += new ItemClickEventHandler(this.bbiEdit_ItemClick);
            this.bbiDelete.Caption = "X\x00f3a";
            this.bbiDelete.Id = 5;
            this.bbiDelete.ImageIndex = 2;
            this.bbiDelete.Name = "bbiDelete";
            this.bbiDelete.ItemClick += new ItemClickEventHandler(this.bbiDelete_ItemClick);
            this.bbiSave.Caption = "Lưu";
            this.bbiSave.Id = 4;
            this.bbiSave.ImageIndex = 0;
            this.bbiSave.Name = "bbiSave";
            this.bbiSave.ItemClick += new ItemClickEventHandler(this.bbiSave_ItemClick);
            this.bbiPrint.Caption = "In";
            this.bbiPrint.Id = 6;
            this.bbiPrint.ImageIndex = 0x17;
            this.bbiPrint.Name = "bbiPrint";
            this.bbiPrint.ItemClick += new ItemClickEventHandler(this.bbiPrint_ItemClick);
            this.bbiExport.Caption = "Xuất";
            this.bbiExport.Id = 9;
            this.bbiExport.ImageIndex = 0x10;
            this.bbiExport.Name = "bbiExport";
            this.bbiExport.ItemClick += new ItemClickEventHandler(this.bbiExport_ItemClick);
            this.bbiRefresh.Caption = "Nạp Lại";
            this.bbiRefresh.Id = 7;
            this.bbiRefresh.ImageIndex = 14;
            this.bbiRefresh.Name = "bbiRefresh";
            this.bbiClose.Caption = "Đ\x00f3ng";
            this.bbiClose.Id = 8;
            this.bbiClose.ImageIndex = 5;
            this.bbiClose.Name = "bbiClose";
            this.bbiClose.ItemClick += new ItemClickEventHandler(this.bbiClose_ItemClick);
            this.imageCollection2.ImageStream = (ImageCollectionStreamer)manager.GetObject("imageCollection2.ImageStream");
            this.imageCollection2.Images.SetKeyName(20, "11.png");
            this.imageCollection2.Images.SetKeyName(0x15, "Them.png");
            this.imageCollection2.Images.SetKeyName(0x16, "plus.png");
            this.imageCollection2.Images.SetKeyName(0x17, "print-16x16.png");
            this.repositoryItemImageComboBox1.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.repositoryItemImageComboBox1.Appearance.Options.UseFont = true;
            this.repositoryItemImageComboBox1.AutoHeight = false;
            this.repositoryItemImageComboBox1.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repositoryItemImageComboBox1.Items.AddRange(new ImageComboBoxItem[] { new ImageComboBoxItem("<Tất cả>", 0, -1), new ImageComboBoxItem("<Đang thử việc>", 1, -1), new ImageComboBoxItem("<Đang l\x00e0m việc>", 2, -1), new ImageComboBoxItem("<Đang ngưng việc>", 3, -1), new ImageComboBoxItem("<Đ\x00e3 nghỉ việc>", 4, -1) });
            this.repositoryItemImageComboBox1.Name = "repositoryItemImageComboBox1";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.splitContainerControl1);
            base.Controls.Add(this.barDockControlLeft);
            base.Controls.Add(this.barDockControlRight);
            base.Controls.Add(this.barDockControlBottom);
            base.Controls.Add(this.barDockControlTop);
            base.Name = "xucPermision";
            base.Size = new Size(0x3ec, 0x248);
            this.repositoryItemPictureEdit1.EndInit();
            this.splitContainerControl1.EndInit();
            this.splitContainerControl1.ResumeLayout(false);
            this.tlPermision.EndInit();
            this.barManager1.EndInit();
            this.imageCollection2.EndInit();
            this.repositoryItemImageComboBox1.EndInit();
            base.ResumeLayout(false);
        }

        private void Recheck(CellValueChangedEventArgs e)
        {
            int num;
            if (e.Column.FieldName == "AllowAdd")
            {
                if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colAllowAdd)))
                {
                    e.Node.SetValue(this.colAllowAdd, false);
                    e.Node.ParentNode.SetValue(this.colAllowAdd, false);
                }
                else
                {
                    e.Node.SetValue(this.colAllowAdd, e.Value);
                    if (e.Node.HasChildren)
                    {
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colAllowAccess, true);
                            this.Recheck("AllowAccess", e.Node, true);
                            e.Node.SetValue(this.colAllowAdd, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowAdd, true);
                                this.Recheck("AllowAdd", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colAllowAdd, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowAdd, false);
                                this.Recheck("AllowAdd", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
            }
            else if (e.Column.FieldName == "AllowEdit")
            {
                if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colAllowEdit)))
                {
                    e.Node.SetValue(this.colAllowEdit, false);
                    e.Node.ParentNode.SetValue(this.colAllowEdit, false);
                }
                else
                {
                    e.Node.SetValue(this.colAllowEdit, e.Value);
                    if (e.Node.HasChildren)
                    {
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colAllowAccess, true);
                            this.Recheck("AllowAccess", e.Node, true);
                            e.Node.SetValue(this.colAllowEdit, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowEdit, true);
                                this.Recheck("AllowEdit", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colAllowEdit, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowEdit, false);
                                this.Recheck("AllowEdit", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
            }
            else if (e.Column.FieldName == "AllowDelete")
            {
                if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colAllowDelete)))
                {
                    e.Node.SetValue(this.colAllowDelete, false);
                    e.Node.ParentNode.SetValue(this.colAllowDelete, false);
                }
                else
                {
                    e.Node.SetValue(this.colAllowDelete, e.Value);
                    if (e.Node.HasChildren)
                    {
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colAllowAccess, true);
                            this.Recheck("AllowAccess", e.Node, true);
                            e.Node.SetValue(this.colAllowDelete, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowDelete, true);
                                this.Recheck("AllowDelete", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colAllowDelete, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowDelete, false);
                                this.Recheck("AllowDelete", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
            }
            else if (e.Column.FieldName == "AllowAccess")
            {
                if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colAllowAccess)))
                {
                    e.Node.SetValue(this.colAllowAccess, false);
                    e.Node.ParentNode.SetValue(this.colAllowAccess, false);
                }
                else
                {
                    e.Node.SetValue(this.colAllowAccess, e.Value);
                    if (e.Node.HasChildren)
                    {
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colAllowAccess, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowAccess, true);
                                this.Recheck("AllowAccess", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colAllowAccess, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowAccess, false);
                                this.Recheck("AllowAccess", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
            }
            else if (e.Column.FieldName == "AllowPrint")
            {
                if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colAllowPrint)))
                {
                    e.Node.SetValue(this.colAllowPrint, false);
                    e.Node.ParentNode.SetValue(this.colAllowPrint, false);
                }
                else
                {
                    e.Node.SetValue(this.colAllowPrint, e.Value);
                    if (e.Node.HasChildren)
                    {
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colAllowAccess, true);
                            this.Recheck("AllowAccess", e.Node, true);
                            e.Node.SetValue(this.colAllowPrint, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowPrint, true);
                                this.Recheck("AllowPrint", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colAllowPrint, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowPrint, false);
                                this.Recheck("AllowPrint", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
            }
            else if (e.Column.FieldName == "AllowExport")
            {
                if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colAllowExport)))
                {
                    e.Node.SetValue(this.colAllowExport, false);
                    e.Node.ParentNode.SetValue(this.colAllowExport, false);
                }
                else
                {
                    e.Node.SetValue(this.colAllowExport, e.Value);
                    if (e.Node.HasChildren)
                    {
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colAllowAccess, true);
                            this.Recheck("AllowAccess", e.Node, true);
                            e.Node.SetValue(this.colAllowExport, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowExport, true);
                                this.Recheck("AllowExport", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colAllowExport, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowExport, false);
                                this.Recheck("AllowExport", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
            }
            else if (e.Column.FieldName == "AllowImport")
            {
                if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colAllowImport)))
                {
                    e.Node.SetValue(this.colAllowImport, false);
                    e.Node.ParentNode.SetValue(this.colAllowImport, false);
                }
                else
                {
                    e.Node.SetValue(this.colAllowImport, e.Value);
                    if (e.Node.HasChildren)
                    {
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colAllowAccess, true);
                            this.Recheck("AllowAccess", e.Node, true);
                            e.Node.SetValue(this.colAllowImport, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowImport, true);
                                this.Recheck("AllowImport", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colAllowImport, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colAllowImport, false);
                                this.Recheck("AllowImport", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
            }
        }

        private void Recheck(string FieldName, TreeListNode node, object value)
        {
            int num;
            if ((FieldName == "Active") && node.HasChildren)
            {
                for (num = 0; num < node.Nodes.Count; num++)
                {
                    node.Nodes[num].SetValue(this.colActive, value);
                    this.Recheck("Active", node.Nodes[num], value);
                }
            }
            if (FieldName == "AllowAdd")
            {
                if (node.HasChildren)
                {
                    for (num = 0; num < node.Nodes.Count; num++)
                    {
                        node.Nodes[num].SetValue(this.colAllowAdd, value);
                        this.Recheck("AllowAdd", node.Nodes[num], value);
                    }
                }
            }
            else if (FieldName == "AllowEdit")
            {
                if (node.HasChildren)
                {
                    for (num = 0; num < node.Nodes.Count; num++)
                    {
                        node.Nodes[num].SetValue(this.colAllowEdit, value);
                        this.Recheck("AllowEdit", node.Nodes[num], value);
                    }
                }
            }
            else if (FieldName == "AllowDelete")
            {
                if (node.HasChildren)
                {
                    for (num = 0; num < node.Nodes.Count; num++)
                    {
                        node.Nodes[num].SetValue(this.colAllowDelete, value);
                        this.Recheck("AllowDelete", node.Nodes[num], value);
                    }
                }
            }
            else if (FieldName == "AllowAccess")
            {
                if (node.HasChildren)
                {
                    for (num = 0; num < node.Nodes.Count; num++)
                    {
                        node.Nodes[num].SetValue(this.colAllowAccess, value);
                        this.Recheck("AllowAccess", node.Nodes[num], value);
                    }
                }
            }
            else if (FieldName == "AllowPrint")
            {
                if (node.HasChildren)
                {
                    for (num = 0; num < node.Nodes.Count; num++)
                    {
                        node.Nodes[num].SetValue(this.colAllowPrint, value);
                        this.Recheck("AllowPrint", node.Nodes[num], value);
                    }
                }
            }
            else if (FieldName == "AllowExport")
            {
                if (node.HasChildren)
                {
                    for (num = 0; num < node.Nodes.Count; num++)
                    {
                        node.Nodes[num].SetValue(this.colAllowExport, value);
                        this.Recheck("AllowExport", node.Nodes[num], value);
                    }
                }
            }
            else if ((FieldName == "AllowImport") && node.HasChildren)
            {
                for (num = 0; num < node.Nodes.Count; num++)
                {
                    node.Nodes[num].SetValue(this.colAllowImport, value);
                    this.Recheck("AllowImport", node.Nodes[num], value);
                }
            }
        }

        private void tlPermision_CellValueChanging(object sender, CellValueChangedEventArgs e)
        {
            if (this.m_GroupID == "admin")
            {
                XtraMessageBox.Show("Nh\x00f3m người d\x00f9ng n\x00e0y kh\x00f4ng được thay đổi", "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (MyRule.IsEdit("bbiUserGroup"))
            {
                Cursor.Current = Cursors.WaitCursor;
                if (e.Column.FieldName == "Active")
                {
                    if ((e.Node.ParentNode != null) && !Convert.ToBoolean(e.Node.ParentNode.GetValue(this.colActive)))
                    {
                        e.Node.SetValue(this.colActive, false);
                        e.Node.ParentNode.SetValue(this.colActive, false);
                        return;
                    }
                    e.Node.SetValue(this.colActive, e.Value);
                    if (Convert.ToBoolean(e.Value))
                    {
                        e.Node.SetValue(this.colAllowAdd, true);
                        this.Recheck("AllowAdd", e.Node, true);
                        e.Node.SetValue(this.colAllowAccess, true);
                        this.Recheck("AllowAccess", e.Node, true);
                        e.Node.SetValue(this.colAllowDelete, true);
                        this.Recheck("AllowDelete", e.Node, true);
                        e.Node.SetValue(this.colAllowEdit, true);
                        this.Recheck("AllowEdit", e.Node, true);
                        e.Node.SetValue(this.colAllowExport, true);
                        this.Recheck("AllowExport", e.Node, true);
                        e.Node.SetValue(this.colAllowImport, true);
                        this.Recheck("AllowImport", e.Node, true);
                        e.Node.SetValue(this.colAllowPrint, true);
                        this.Recheck("AllowPrint", e.Node, true);
                    }
                    else
                    {
                        e.Node.SetValue(this.colAllowAdd, false);
                        this.Recheck("AllowAdd", e.Node, false);
                        e.Node.SetValue(this.colAllowAccess, false);
                        this.Recheck("AllowAccess", e.Node, false);
                        e.Node.SetValue(this.colAllowDelete, false);
                        this.Recheck("AllowDelete", e.Node, false);
                        e.Node.SetValue(this.colAllowEdit, false);
                        this.Recheck("AllowEdit", e.Node, false);
                        e.Node.SetValue(this.colAllowExport, false);
                        this.Recheck("AllowExport", e.Node, false);
                        e.Node.SetValue(this.colAllowImport, false);
                        this.Recheck("AllowImport", e.Node, false);
                        e.Node.SetValue(this.colAllowPrint, false);
                        this.Recheck("AllowPrint", e.Node, false);
                    }
                    if (e.Node.HasChildren)
                    {
                        int num;
                        if (Convert.ToBoolean(e.Value))
                        {
                            e.Node.SetValue(this.colActive, true);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colActive, true);
                                this.Recheck("Active", e.Node.Nodes[num], true);
                            }
                        }
                        else
                        {
                            e.Node.SetValue(this.colActive, false);
                            e.Node.SetValue(this.colActive, false);
                            for (num = 0; num < e.Node.Nodes.Count; num++)
                            {
                                e.Node.Nodes[num].SetValue(this.colActive, false);
                                this.Recheck("Active", e.Node.Nodes[num], false);
                            }
                        }
                    }
                }
                this.Recheck(e);
                Cursor.Current = Cursors.Default;
            }
        }
    }

}
